import 'package:safetymonitor/generated/json/base/json_convert_content.dart';
import 'package:safetymonitor/app/data/entities/home/duty/duty_schedule_entity.dart';

DutyScheduleEntity $DutyScheduleEntityFromJson(Map<String, dynamic> json) {
  final DutyScheduleEntity dutyScheduleEntity = DutyScheduleEntity();
  final int? id = jsonConvert.convert<int>(json['id']);
  if (id != null) {
    dutyScheduleEntity.id = id;
  }
  final int? companyId = jsonConvert.convert<int>(json['companyId']);
  if (companyId != null) {
    dutyScheduleEntity.companyId = companyId;
  }
  final String? companyName = jsonConvert.convert<String>(json['companyName']);
  if (companyName != null) {
    dutyScheduleEntity.companyName = companyName;
  }
  final int? scheduleConfigId = jsonConvert.convert<int>(json['scheduleConfigId']);
  if (scheduleConfigId != null) {
    dutyScheduleEntity.scheduleConfigId = scheduleConfigId;
  }
  final String? scheduleName = jsonConvert.convert<String>(json['scheduleName']);
  if (scheduleName != null) {
    dutyScheduleEntity.scheduleName = scheduleName;
  }
  final String? dutyStartDate = jsonConvert.convert<String>(json['dutyStartDate']);
  if (dutyStartDate != null) {
    dutyScheduleEntity.dutyStartDate = dutyStartDate;
  }
  final String? dutyEndDate = jsonConvert.convert<String>(json['dutyEndDate']);
  if (dutyEndDate != null) {
    dutyScheduleEntity.dutyEndDate = dutyEndDate;
  }
  final String? dutyPerson = jsonConvert.convert<String>(json['dutyPerson']);
  if (dutyPerson != null) {
    dutyScheduleEntity.dutyPerson = dutyPerson;
  }
  final String? personScheduleType = jsonConvert.convert<String>(json['personScheduleType']);
  if (personScheduleType != null) {
    dutyScheduleEntity.personScheduleType = personScheduleType;
  }
  final String? personScheduleTypeCode = jsonConvert.convert<String>(json['personScheduleTypeCode']);
  if (personScheduleTypeCode != null) {
    dutyScheduleEntity.personScheduleTypeCode = personScheduleTypeCode;
  }
  final String? dutyLeader = jsonConvert.convert<String>(json['dutyLeader']);
  if (dutyLeader != null) {
    dutyScheduleEntity.dutyLeader = dutyLeader;
  }
  final String? leaderScheduleType = jsonConvert.convert<String>(json['leaderScheduleType']);
  if (leaderScheduleType != null) {
    dutyScheduleEntity.leaderScheduleType = leaderScheduleType;
  }
  final String? leaderScheduleTypeCode = jsonConvert.convert<String>(json['leaderScheduleTypeCode']);
  if (leaderScheduleTypeCode != null) {
    dutyScheduleEntity.leaderScheduleTypeCode = leaderScheduleTypeCode;
  }
  final String? createTime = jsonConvert.convert<String>(json['createTime']);
  if (createTime != null) {
    dutyScheduleEntity.createTime = createTime;
  }
  final int? dutyType = jsonConvert.convert<int>(json['dutyType']);
  if (dutyType != null) {
    dutyScheduleEntity.dutyType = dutyType;
  }
  return dutyScheduleEntity;
}

Map<String, dynamic> $DutyScheduleEntityToJson(DutyScheduleEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['companyId'] = entity.companyId;
  data['companyName'] = entity.companyName;
  data['scheduleConfigId'] = entity.scheduleConfigId;
  data['scheduleName'] = entity.scheduleName;
  data['dutyStartDate'] = entity.dutyStartDate;
  data['dutyEndDate'] = entity.dutyEndDate;
  data['dutyPerson'] = entity.dutyPerson;
  data['personScheduleType'] = entity.personScheduleType;
  data['personScheduleTypeCode'] = entity.personScheduleTypeCode;
  data['dutyLeader'] = entity.dutyLeader;
  data['leaderScheduleType'] = entity.leaderScheduleType;
  data['leaderScheduleTypeCode'] = entity.leaderScheduleTypeCode;
  data['createTime'] = entity.createTime;
  data['dutyType'] = entity.dutyType;
  return data;
}

extension DutyScheduleEntityExtension on DutyScheduleEntity {
  DutyScheduleEntity copyWith({
    int? id,
    int? companyId,
    String? companyName,
    int? scheduleConfigId,
    String? scheduleName,
    String? dutyStartDate,
    String? dutyEndDate,
    String? dutyPerson,
    String? personScheduleType,
    String? personScheduleTypeCode,
    String? dutyLeader,
    String? leaderScheduleType,
    String? leaderScheduleTypeCode,
    String? createTime,
    int? dutyType,
  }) {
    return DutyScheduleEntity()
      ..id = id ?? this.id
      ..companyId = companyId ?? this.companyId
      ..companyName = companyName ?? this.companyName
      ..scheduleConfigId = scheduleConfigId ?? this.scheduleConfigId
      ..scheduleName = scheduleName ?? this.scheduleName
      ..dutyStartDate = dutyStartDate ?? this.dutyStartDate
      ..dutyEndDate = dutyEndDate ?? this.dutyEndDate
      ..dutyPerson = dutyPerson ?? this.dutyPerson
      ..personScheduleType = personScheduleType ?? this.personScheduleType
      ..personScheduleTypeCode = personScheduleTypeCode ?? this.personScheduleTypeCode
      ..dutyLeader = dutyLeader ?? this.dutyLeader
      ..leaderScheduleType = leaderScheduleType ?? this.leaderScheduleType
      ..leaderScheduleTypeCode = leaderScheduleTypeCode ?? this.leaderScheduleTypeCode
      ..createTime = createTime ?? this.createTime
      ..dutyType = dutyType ?? this.dutyType;
  }
}